#include "../three20220924/List.h"
#include "../three20220917/Vector.h"
using namespace std;

namespace YX
{
    template<class Iterator,typename Ref,typename Ptr>
    class __reverse_iterator
    {
        typedef __reverse_iterator<Iterator,Ref,Ptr> R_Iterator;
        private:
            Iterator _ri;
        public:
            __reverse_iterator(const Iterator& it)
                :_ri(it)
            {

            }
            
            R_Iterator& operator++()
            {
                --_ri;
                return *this;
            }

            R_Iterator& operator--()
            {
                ++_ri;
                return *this;
            }
            
            Ref operator*()
            {
                Iterator tmp=_ri;

                --tmp;

                return *tmp;
            }

            Ptr operator->()
            {
                return &(operator*());
            }

            bool operator==(const R_Iterator& r)
            {
                return _ri==r._ri;
            }

            bool operator!=(const R_Iterator& r)
            {
                return _ri!=r._ri;
            }

    };

    void TestReverseIterator()
    {
        List<int> l;
        l.push_back(1);
        l.push_back(2);
        l.push_back(3);
        l.push_back(4);
        l.push_back(5);

        List<int>::Reverse_Iterator rit=l.rbegin();
        while(rit!=l.rend())
        {
            cout<<*rit<<endl;
            ++rit;
        }

    }

};
